<?php
namespace addons\upyunup\controller;
use addons\upyunup\service\Provide;
use addons\upyunup\Upyunup;
use think\addons\Controller;

class AdminIndex extends Controller
{
    /**
     * 模板配置参数
     * @var array
     */
    protected $config = [
        'tpl_replace_string'=>[
            '__STATIC__' => '/static/admin'
        ]
    ];
    public function index()
    {
        return $this->fetch();
    }

    public function upfile()
    {
        if(!isset($_FILES['file']['name'])) return false;
        //文件格式
        $ext = pathinfo($_FILES['file']['name'])['extension'];
        return  json([
            "code" => 1,
            "msg"  => "上传成功",
            "data" => Provide::upload(getMikUpdir().getmd5File().'.'.$ext,getMikUpdir())
        ]);
    }

    public function downloads()
    {
       return (new Upyunup())->upydownhook([
           "src" => "http://up.gwypxw.com/20210311/1615446470.jpg"
       ]);
    }
}